package org.nfIt.controller;

import io.swagger.v3.oas.annotations.Operation;
import org.nfIt.entity.product.Category;
import org.nfIt.service.CategoryService;
import org.nfIt.vo.common.Result;
import org.nfIt.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClossName:CategoryController
 * Pakage:org.nfIt.controller
 * Description
 *
 * 查询所有分类，树形显示（与后端不同后端是懒加载）
 *
 * @Author L
 * @Create 2024/9/21 17:18
 * @Version 2023.1.3
 */
@RestController
@RequestMapping(value="/api/product/category")
//@CrossOrigin //跨域问题
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 查询所有分类
     */
    @Operation(summary = "获取分类树形数据")
    @GetMapping("findCategoryTree")
    public Result findCategoryTree(){
        List<Category> list = categoryService.findCategoryTree();
        return Result.build(list,  ResultCodeEnum.SUCCESS);
    }


}
